home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
SourceCode
/
Registration
/
send.m
< prev
Wrap
Text File
|
1992-12-19
|
989b
|
53 lines
/*
* send.m:
* do a UDP broadcast
*/
#import "Registration.h"
#include <sys/types.h>
#include <sys/socket.h>
#import <pwd.h>
#import <netinet/in.h>
#import <netdb.h>
main(int argc,char **argv)
{
struct sockaddr_in sin;
struct servent *sp;
int sock;
int cc;
struct hostent *host = 0;
struct regNetToken nt;
struct passwd *pw;
sin.sin_family = AF_INET;
sin.sin_port = 45743; /* our port */
host = gethostbyname("broadcasthost");
sin.sin_family = host->h_addrtype;
memcpy(&sin.sin_addr,host->h_addr_list[0],host->h_length);
sock = socket(AF_INET,SOCK_DGRAM,0); /* get a socket */
argc--;
argv++;
memset(&nt,0,sizeof(nt));
pw = getpwuid(getuid());
strncpy(nt.username,pw->pw_name,sizeof(nt.username)-1);
strncpy(nt.person,pw->pw_gecos,sizeof(nt.person)-1);
nt.command = C_PRINT;
while(argc){
strcat(nt.userData,*argv);
strcat(nt.userData," ");
argc--;
argv++;
}
cc = sendto(sock,&nt,sizeof(nt),0,(struct sockaddr *)&sin,sizeof(sin));
exit(0);
}